package org.brownflat.watergate.scm.svn;

import org.brownflat.watergate.scm.RevisionChange;
import org.brownflat.watergate.scm.RevisionChangeType;
import org.brownflat.watergate.scm.RevisionElementType;
import org.tmatesoft.svn.core.SVNNodeKind;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
public class SubversionRevisionChange implements RevisionChange {
    private String path;
    private RevisionChangeType revisionChangeType;
    private RevisionElementType revisionElementType;

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public RevisionChangeType getRevisionChangeType() {
        return revisionChangeType;
    }

    public void setRevisionChangeType(RevisionChangeType revisionChangeType) {
        this.revisionChangeType = revisionChangeType;
    }

    public RevisionElementType getRevisionElementType() {
        return revisionElementType;
    }

    public void setRevisionElementType(RevisionElementType revisionElementType) {
        this.revisionElementType = revisionElementType;
    }

    public void setRevisionChangeType(char type) {
        if('A' == type)  {
            setRevisionChangeType(RevisionChangeType.ADD);
        } else if ('D' == type) {
            setRevisionChangeType(RevisionChangeType.DELETE);
        } else if ('M' == type) {
            setRevisionChangeType(RevisionChangeType.MODIFY);
        } else if ('R' == type) {
            setRevisionChangeType(RevisionChangeType.REPLACE);
        } else {
            setRevisionChangeType(RevisionChangeType.UNKNOWN);
        }
    }

    public void setRevisionElementType(SVNNodeKind kind) {
        if(SVNNodeKind.DIR.equals(kind)){
            setRevisionElementType(RevisionElementType.DIRECTORY);
        } else if(SVNNodeKind.FILE.equals(kind)) {
            setRevisionElementType(RevisionElementType.FILE);
        } else {
            setRevisionElementType(RevisionElementType.OTHER);
        }
    }
}
